package com.alks.function.mapper;

import com.alks.common.data.dto.SysUserTokenDTO;
import com.alks.entity.data.entity.*;
import com.alks.entity.data.entity.dispatch.DevelopStyle;
import com.alks.entity.data.entity.dispatch.DevelopStyleColor;
import com.alks.entity.data.entity.dispatch.OemLotHead;
import com.alks.entity.data.entity.excel.OrderProductTable;
import com.alks.entity.data.entity.excel.PcOrderHead2;
import com.alks.entity.data.entity.excel.SampleLot;
import com.alks.function.data.dto.pcfactoryquery.PartBfInDto;
import com.alks.function.data.dto.pcfactoryquery.PartBfOutDto;
import com.alks.function.data.dto.pcfactoryquery.PartStockHeadDto;
import com.alks.function.data.request.factoryquery.PartBfInRequest;
import com.alks.function.data.request.factoryquery.PartBfOutRequest;
import com.alks.function.data.request.factoryquery.PartStockRequest;
import com.alks.function.data.request.order.*;
import com.alks.function.data.request.yield.CollectionPointRequest;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mapstruct.Mapper;

import java.io.InputStream;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
public interface PcOrderHeadMapping extends BaseMapper<PcOrderHead> {
    List<PcOrderDetail> orderList(PcOrderListRequest request);

    BigDecimal countOrderNum(PcOrderListRequest request);

    List<PcAggSchedule> pcAggSchList(PcAggScheduleRequest request);

    BigDecimal getTotalOrders(PcAggScheduleRequest request);

    BigDecimal getTotalDays(PcAggScheduleRequest request);

    Long getOrderTotalSize(PcOrderListRequest request);

    Long getAggSchTotalSize(PcAggScheduleRequest request);

    List<String> getOrderBrand();

    List<String> getOrderSeason();

    List<String> getOrderSample();

    List<PcPhoto> getPhotoPath();

    InputStream getPhotoStream(@Param("style") String style,@Param("color") String color);

    void setPhoto(@Param("lotNo") String lotNo,@Param("path") String path);

    List<CollectionPoint> collectionPointList(CollectionPointRequest request);

    Long getCollectionTotal(CollectionPointRequest request);

    BigDecimal getCollectionOrders(CollectionPointRequest request);

    List<String> getCollectionBrands();

    List<String> getCollectionSeasons();

    List<String> getCollectionSamples();

    List<String> pcAggScheduleCondition();

    List<PcOrderDataRep> getPcOrderDataList(PcOrderDataRequest request);

    Long getPcOrderDataListTotal(PcOrderDataRequest request);

    List<PcOrderShoePhotoFixRep> getPcOrderShoePhotoFix(PcOrderShoePhotoFixRequest request);

    Long getPcOrderShoePhotoFixTotal(PcOrderShoePhotoFixRequest request);

    void updatePcOrderData(List<PcOrderDataRep> request);

    void upDateShoeDetail(@Param("request") PcOrderShoePhotoFixRep request,@Param("list") List<String> list);

    void updateShowCheck(PcOrderShoePhotoFixRep request);

    void updatePcOrderDataSac( PcOrderDataSacRequest request);

    @Select("SELECT PROD_USER_NAME FROM PC_ORDER_PROD_STATUS WHERE PROD_STEP like concat('%','成型','%') GROUP BY PROD_USER_NAME")
    List<String> getProdUserName();

    List<PcOrderDataRsjRep> getPcOrderDataRsj(PcOrderDataRsjRequest request);

    Long getPcOrderDataRsjInTotal(PcOrderDataRsjRequest request);

    Long getPcOrderDataRsjTotal(PcOrderDataRsjRequest request);

    List<PcOrderDataTbsRep> getPcOrderDataTbs(PcOrderDataTbsRequest request);

    Long getPcOrderDataTbsTotal(PcOrderDataTbsRequest request);

    void outPcOrderDataTbs(@Param("list")  List<PcOrderProdStatus> list);

    List<PcOrderProdStatus> getProds(@Param("list") List<String> list);

    List<PcOrderDataOutRep> PcOrderDataOutRecord(@Param("request") PcOrderDataTbsRequest request,@Param("username") String username);

    Long PcOrderDataOutRecordTotal(@Param("request") PcOrderDataTbsRequest request,@Param("username") String username);

    void deleteRecordByLots(@Param("request") PcOrderDataInOutRequest request);

    @Select("SELECT SAMPLE_TYPE  FROM PC_ORDER_HEAD \n" +
            "WHERE SAMPLE_TYPE IS NOT NULL\n" +
            "GROUP BY SAMPLE_TYPE\n" +
            "ORDER BY SAMPLE_TYPE")
    List<String> getPcOrderSummaryAlsSamples();

    @Select("SELECT BRAND  FROM PC_ORDER_HEAD \n" +
            "WHERE BRAND IS NOT NULL\n" +
            "GROUP BY BRAND\n" +
            "ORDER BY BRAND")
    List<String> getPcOrderSummaryAlsBrands();

    @Select("SELECT SEASON_TYPE  FROM PC_ORDER_HEAD \n" +
            "WHERE SEASON_TYPE IS NOT NULL\n" +
            "GROUP BY SEASON_TYPE\n" +
            "ORDER BY SEASON_TYPE")
    List<String> getPcOrderSummaryAlsSeasons();

    List<PcOrderSummaryAnalysisRep> pcOrderDataSummaryAls(PcOrderSummaryAnalysisRequest request);

    Integer pcOrderDataSummaryAlsTotal(PcOrderSummaryAnalysisRequest request);

    BigDecimal pcOrderDataSummaryAlsOrderSum(PcOrderSummaryAnalysisRequest request);

    List<PcProductionDtRep> pcProductionDt(PcProductionDtRequest request);


    List<String> pcProductionDtMarkGet();


    List<PcOrderStyleColorDdRep> pcOrderStyleColorDd(PcOrderShoePhotoFixRequest request);

    void updatePcOrderStyleColorCheck(PcOrderStyleColorDdCheckRequest request);

    List<PcOrderStyleColorDdDetailRep> pcOrderStyleColorDdDetail(@Param("strs") List<String> strs);

    void updatePcOrderStyleColorDdDetail(PcOrderStyleColorDdDetailRep request);

    @Update("UPDATE PC_YP_LOT_HEAD SET ORDER_TYPE = #{sampleType} WHERE LOT_NO = #{lotNo}")
    void updatePcYpLotHead(@Param("lotNo") String lotNo,@Param("sampleType") String sampleType);

    List<PcOrderPickingOperateRep> getPickingOperate(PcOrderPickingOperateRequest request);

    Integer getPickingOperateTotal(PcOrderPickingOperateRequest request);

    List<PcOrderPickingOperateDetailRep> getPickingOperateDetail(String lotNo);


    void setTypeNameInPickingOperate(PcOrderCTN request);

    void setMtlNoEmptyPickingOperate(@Param("lotNo")String lotNo,@Param("list") List<PcOrderPickingOperateDetailRep> list);

    List<PcOrderPickingOperateDetailRep> getPcPurPreMtl(@Param("lotNo")String lotNo,@Param("list") List<PcOrderPickingOperateDetailRep> list);

    void setMtlNoProPickingOperate(@Param("lotNo")String lotNo,@Param("rep") PcOrderPickingOperateDetailRep rep,@Param("mtlNo") String mtlNo);

    void setMtlNoCopyInLotNoMtl(@Param("lotNo") String lotNo,@Param("list") List<PcOrderPickingOperateDetailRep> list,@Param("username") String userName);

    void setPcOrderMtlCheck(@Param("lotNos") List<String> lotNos,@Param("username") String userName);

    void setPcOrderMtlUnCheck(@Param("lotNos") List<String> lotNos,@Param("username") String userName);

    void pcOrderShielding(@Param("lots") List<String> lots, @Param("name") SysUserTokenDTO name);

    void deletePcOrderShielding(@Param("lots") List<String> lots);

    List<String> pcOrderShieldingList(@Param("lotNo") String lotNo);

    Integer pcOrderShieldingListTotal(@Param("lotNo") String lotNo);

    @Select("SELECT DISTINCT PHOTO_PATH FROM PC_STYLE_PHOTO")
    List<String> getAllPhotoPath();

    @Select("SELECT DISTINCT  MOLD_NO FROM PC_ORDER_HEAD WHERE MOLD_NO IS NOT NULl")
    List<String> getOrderMold();

    @Select("SELECT DISTINCT LAST_NO FROM PC_ORDER_HEAD WHERE LAST_NO IS NOT NULL")
    List<String> getOrderLast();

    String getMtlNo(PcOrderMaterToAllRep rep);

    void updateCreateMtlNo1(@Param("mtlNo") String mtlNo1,@Param("lotNo") String lotNo,@Param("rep") PcOrderPickingOperateDetailRep rep);

    int updateCreateMtlNo2(@Param("mtlTypeNo") String mtlTypeNo,@Param("rep") PcOrderMaterToAllRep rep,@Param("username")String username);

    List<OutStockDetailResp> outStockMessageList(PcOrderSummaryAnalysisRequest request);

    BigDecimal getProdTotal(PcOrderSummaryAnalysisRequest request);

    List<PartBfInDto> getPcSlipPart(PartBfInRequest request);

    List<PartBfOutDto> queryPartBfOut(PartBfOutRequest request);

    List<PartStockHeadDto> queryPartBfStockHead(PartStockRequest request);

    List<PcSlipDetailPart> getStockIn(String mtlNo);

    List<PcSlipDetailPart> getStockOut(String mtlNo);

    List<OrderProductTable> downloadPcProductDt(PcProductionDtRequest request);

    @Select("select distinct  PROD_USER_NAME from PC_ORDER_PROD_STATUS where PROD_SEQ = #{i}")
    List<String> getProdUser(Integer i);

    List<String> getByBrand(@Param("brand") String brand);

    List<String> getByOrderId(@Param("orderId") String orderId);

    void insertOrderType(PcOrderHead2 pcOrderHead2);

    void insertIntoPcYpLotHead(PcYpLotHead pcYpLotHead);

    DevelopStyleColor selectColorByStyleColor(DevelopStyleColor styleColor);

    DevelopStyle selectByPrimaryKey(DevelopStyle styleInfo);

    int selectExportCfmCount(@Param("companyId") String companyId, @Param("factoryLotNo") String factoryLotNo);

    List<String> selectByLotUUID(OemLotHead oemLotHead);

    void insertOemLot(OemLotHead oemLotHead);


    void insertToPcStyle(@Param("sys") SysUserTokenDTO sys, @Param("pc") PcOrderHead pc);

    @Select("select count(*) from PC_STYLE_PHOTO where style = #{style} and color = #{color}")
    Integer getPcSytyle(PcOrderHead pcOrderHead);

    String getOrderIdByDisPatch(String dispatchNo);

    String getMtlTypeNo(PcOrderPickingOperateDetailRep rep);

    SampleLot querySampleLotById(SampleLot sampleLot);

    void updateProdStatus();

    void deleteProdStatus();

    void deletePcProdCancelMarkOk(String lotNo);

    void insertPcProdMarkOk(@Param("lotNo") String lotNo, @Param("companyId") String companyId);

    String getMtlTypeNoBy(PcOrderPickingOperateDetailRep rep);

    Map<String,Object>  getWorkerNameByDisPatch(@Param("dispatchNo") String dispatchNo);

    BigDecimal getProdQtyByLot(@Param("req") ScanCollectionAllReq req, @Param("choose") String choose);

    @Select("select style style_no,color style_color from PC_ORDER_HEAD where order_id = #{lotNo}")
    DevelopStyleColor getDevelopStyleColor(String lotNo);

    Integer refreshOrderMaterialDaI2(@Param("style") DevelopStyleColor style, @Param("lotNo") String lotNo);

    PcOrderHead getYfStyle(PcOrderHead pcOrderHead);

    PcOrderHead getYfStyle2(PcOrderHead pcOrderHead);

    /**
     * 根据指令获取品牌
     *
     * @param lotList   指令集合
     * @param companyId 公司ID
     * @return 指令-品牌 Map
     */
    List<Map<String, String>> getBrandByLot(@Param("lotList") Set<String> lotList, @Param("companyId") String companyId);

    void deletePcOrderHead(@Param("orderIds") List<String> orderIds);

    void deletePcOrderType(@Param("orderIds") List<String> orderIds);

    Integer getProdByOrderId(String orderId);

    List<PcOrderHead> getBomByStyleColor(PcStyleCraftRep rep);

    @Select("select sample_type from PC_SAMPLE_TYPE")
    List<String> getSampleType();


}
